<!DOCTYPE html>
<html lang="en">
<head>
    <title>微信转发详细页</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style type="text/css">
        .table-width {
            width: 610px;
        }

        .title {
            font-size: 20px;
            text-align: center;
            margin-bottom: 8px;
        }

        .row {
            margin-right: -15px;
            margin-left: 0px;
        }

        .col-md-12 {
            padding-left: 0;
        }

        .infoReport {
            text-align: left;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
    </style>
</head>
<body>
<section v-cloak class="content" id="app" style="min-height:100vh">
    <div class="nav-tabs-custom oaReportNav" v-if="flag==0">
        <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;">
            <li class="active"><a href="#revenue-chart" data-toggle="tab">今日</a></li>
            <li><a href="#revenue-chart" data-toggle="tab">本月</a></li>
            <li v-for="(item,i) in months"><a href="#sales-chart" data-toggle="tab">{{item}}</a></li>
        </ul>
    </div>
    <div class="table-width title" v-if="flag==1">{{userName}}{{time}}微信转发</div>
    <div class="div-td-content-more"><i></i></div>
    <div class="row">
        <div class="col-md-12">
            <div class="infoReport" v-if="isToday=='1'"><i></i>应转发：{{reportShare.todayForward}}&nbsp;&nbsp;已转发：{{reportShare.todayFinishForward}}&nbsp;&nbsp;未转发：{{reportShare.todayNoForward}}
            </div>
            <div class="infoReport" v-if="isToday=='0'"><i></i>应转发：{{reportShare.monthForward}}&nbsp;&nbsp;已转发：{{reportShare.monthFinishForward}}&nbsp;&nbsp;未转发：{{reportShare.monthNoForward}}
            </div>
            <table class="table table-bordered text-center table-width" v-if="isToday=='1'">
                <thead>
                <tr>
                    <th style="width: 380px">转发标题</th>
                    <th style="width: 80px">转发次数</th>
                    <th style="width: 50px">转发</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in list">
                    <td style="text-align: left;">{{item.name}}</td>
                    <td>{{item.forwardNumber}}</td>

                    <td>
                        <i v-if="item.nightFlag===1">
                            <i class="fa fa-check" style="color:#349f2f;"></i>
                        </i>
                        <i v-else-if="item.nightFlag==0">
                            <i class="fa fa-close" style="color:red;"></i>
                        </i>
                    </td>
                </tr>
                </tbody>
            </table>
            <table class="table table-bordered text-center table-width" v-if="isToday=='0'">
                <thead>
                <tr>
                    <th style="width: 100px">日期</th>
                    <th style="width: 280px">转发标题</th>
                    <th style="width: 80px">转发次数</th>
                    <th style="width: 50px">转发</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in monthShareList">
                    <td :rowspan="item.shareDatespan" :class="{hidden: item.shareDatedis}">{{item.shareDate}}</td>
                    <td style="text-align: left;">{{item.name}}</td>
                    <td>{{item.forwardNumber}}</td>
                    <td>
                        <i v-if="item.nightFlag==1">
                            <i class="fa fa-check" style="color:#349f2f;"></i>
                        </i>
                        <i v-else-if="item.nightFlag==0">
                            <i class="fa fa-close" style="color:red;"></i>
                        </i>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>


    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            list: [],
            monthShareList: [],
            months: [],
            userId: getCurrentUser().id,
            companyId: getCurrentUser().companyId,
            time: "",
            today: "",
            userName: "",
            flag: "0",
            isToday: "1",
            reportShare: []
        },
        methods: {
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            getMonths: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");
                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.months.push(that.insert_flg(dateTime, "-", "4"))
                }
            },
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                return newstr;
            },
            getList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.getWechatShare, {
                    "userId": that.userId,
                    "companyId": that.companyId,
                    "shareDate": that.today
                }, function (data) {
                    that.list = data;
                }, true);
            },
            getMonthShareList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.getMonthShareList, {
                    "userId": that.userId,
                    "companyId": that.companyId,
                    "shareMonth": that.time
                }, function (data) {
                    that.monthShareList = that.tablesMergeCell(data);
                }, true);
            },
            getWechatShareTotal: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.wechatShare.getWechatShareTotal, {
                    "userId": that.userId,
                    "shareMonth": that.time
                }, function (data) {
                    that.reportShare = data;
                });
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            }
        },
        mounted: function () {
            //获取前5个月
            this.getMonths();
            var that = this;
            that.flag = $.wyui.page.urlParams.flag;
            if (that.flag == "1") {
                that.userId = $.wyui.page.urlParams.userId;
                that.userName = $.wyui.page.urlParams.userName;
                that.time = $.wyui.page.urlParams.time;
                that.isToday = $.wyui.page.urlParams.isToday;
                //查询某人所属公司
                $.wyui.postMethod(urlConfig.system.user.getUserViewById, {
                    "id": that.userId
                }, function (data) {
                    that.companyId = data.companyId;
                }, true);
            } else {
                that.time = new Date().Format("yyyy-MM");
            }
            if (that.isToday == "1") {
                that.today = new Date().Format("yyyy-MM-dd");
                that.getList();
            } else {
                that.getMonthShareList();
            }
            $("body").delegate(".nav-tabs li a", "click", function () {
                var dateTime = $(this).text();
                if (dateTime == "本月") {
                    that.time = new Date().Format("yyyy-MM");
                } else {
                    that.time = dateTime;
                }
                if (dateTime == "今日") {
                    that.isToday = "1";
                    that.getList();
                } else {
                    that.isToday = "0";
                    that.getMonthShareList();
                }
                that.getWechatShareTotal();
            });
            that.getWechatShareTotal();
        }

    });
</script>

</body>
</html>